<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    let str = "Hello World";
    let reversedStr = "";
    for (let i = str.length - 1; i >= 0; i--) {
        reversedStr += str[i];
    }
    console.log(reversedStr);


    // function reverseString(str) {
    //     if (str === "") // This is the terminal case that will end the recursion
    //         return "";
    //     else return reverseString(str.substr(1)) + str.charAt(0);
    // }

    // reverseString("Hello World"); // Output: "dlroW olleH"
</script>

</html>